<?php
/**
 * the include filter adds the <dig:include /> tag to the page
 *
 * this tag incudes another script
 * you have two options:
 *
 * if you set the src attribute the filter will map the src to an item in the tree
 *
 * if you set the module, controller, and action attributes the filter will run the view action helper
 * which is passes all of the include tag's attributes as well as the current item
 *
 */
class DigCms_View_Filter_Partial extends DigCms_View_Filter_ContentFilter
{
    public $tag = 'partial';

    protected function _callback($matches)
    {
        $attr = $this->getAttributes($matches[0]);
        if (is_array($attr)) {
            $request = Zend_Controller_Front::getInstance()->getRequest()->getParams();
            unset($request['module']);
            unset($request['controller']);
            unset($request['action']);
            $attr['item'] = $this->view->item;
            $attr = array_merge($attr, $request);
            $module = isset($attr['module']) ? $attr['module'] : 'digCms';
            return $this->view->partial($attr['src'], $module, $attr);
        }
        return null;
    }

}
?>
